package com.newasia.server.shiro;

import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.credential.HashedCredentialsMatcher;

/**
 * @author LiChong
 * @description 重写密码验证方法
 * @date 2020/4/1
 */

public class MyHashedCredentialsMatcher extends HashedCredentialsMatcher {

    @Override
    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
        MyShiroTaken myShiroTaken = (MyShiroTaken)token;
        if (((MyShiroTaken) token).isNoPassword()){
            return true;
        }

        Object tokenHashedCredentials = hashProvidedCredentials(myShiroTaken, info);
        Object accountCredentials = getCredentials(info);
        return equals(tokenHashedCredentials, accountCredentials);
    }
}
